﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OpenTKLightingTool.Data;

namespace OpenTKLightingTool.Controls
{
    /// <summary>
    /// Interaction logic for LightProperties.xaml
    /// </summary>
    public partial class LightProperties : UserControl
    {
        private Light mLight;

        public LightProperties()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Sets light to UX
        /// </summary>
        internal void SetLight(Light light)
        {
            mLight = light;
            uxPosition.Value = light.Position;

            uxAmbient.Value = light.Ambient;
            uxDiffuse.Value = light.Diffuse;
            uxSpecular.Value = light.Specular;

            uxConstantAttenuation.Value = light.ConstantAttenuation;
            uxLinearAttenuation.Value = light.LinearAttenuation;
            uxQuadraticAttenuation.Value = light.QuadraticAttenuation;

            uxSpotCutOff.Value = light.SpotCutOff;
            uxSpotDirection.Value = light.SpotDirection;
            uxSpotExponent.Value = light.SpotExponent;
        }

        /// <summary>
        /// Gets light from UX
        /// </summary>
        /// <returns></returns>
        internal Light GetLight(bool isEnabled)
        {
            mLight.IsEnabled = isEnabled;
            mLight.Position = uxPosition.Value;

            mLight.Ambient = uxAmbient.Value;
            mLight.Diffuse = uxDiffuse.Value;
            mLight.Specular = uxSpecular.Value;

            mLight.ConstantAttenuation = uxConstantAttenuation.Value;
            mLight.LinearAttenuation = uxLinearAttenuation.Value;
            mLight.QuadraticAttenuation = uxQuadraticAttenuation.Value;

            mLight.SpotCutOff = uxSpotCutOff.Value;
            mLight.SpotDirection = uxSpotDirection.Value;
            mLight.SpotExponent = uxSpotExponent.Value;

            return mLight;
        }
    }
}
